package WrittenTest;

import java.util.Scanner;

public class test22 {
    // dd冲钻五
    // 算法原理：枚举
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt(), n = in.nextInt(), k = in.nextInt();
        while (m != 0) {
            String s = in.next();
            int count = 0, ret = 0;
            // 枚举
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == 'W') {
                    count++;
                    // 处理连胜的情况
                    if (count >= 3) {
                        ret += k;
                    } else {
                        ret++;
                    }
                } else { // 处理连胜中断的情况
                    ret--;
                    count = 0;
                }
            }
            System.out.println(ret);
            m--;
        }
    }
}
